﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Match.Foundation.Business.Classes;
using Match.ManagementApplication.AbstractClasses;
using Match.ManagementApplication.Classes;

namespace Match.ManagementApplication.Forms
{
    public partial class frmRaceManagement : MatchForm
    {
        #region Constructor
        public frmRaceManagement(FormName FormName, String ShownName, String ShownDescription)
            : base(FormName, ShownName, ShownDescription)
        {
            InitializeComponent();
            Text = ShownName;
            listViewRaces.Tag = new Dictionary<Guid, ListViewItem>();
            listViewStartClasses.Tag = new Dictionary<Guid, ListViewItem>();
        }
        #endregion

        #region FormEvents
        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void frmRaceManagement_Load(object sender, EventArgs e)
        {
            FormHelper.getInstance().InitializeListViewWithRaceListView(listViewRaces);
            FormHelper.getInstance().InitializeListViewWithStartClassListView(listViewStartClasses);
        }
        #endregion

        private void listViewStartClasses_DoubleClick(object sender, EventArgs e)
        {
            StartClass StartClass = StartClass.Get((Guid) listViewStartClasses.SelectedItems[0].Tag);
            frmStartClass StartClassForm = new frmStartClass(FormName.StartClassEdit, "Startklasse bearbeiten", "Hier können Sie alle Daten der Startklasse bearbeiten.", StartClass);
            StartClassForm.ShowDialog();
            FormHelper.getInstance().InitializeListViewWithStartClassListView(listViewStartClasses);
        }

        private void buttonNewStartClass_Click(object sender, EventArgs e)
        {
            frmStartClass StartClassForm = new frmStartClass(FormName.StartClassEdit, "Startklasse bearbeiten", "Hier können Sie alle Daten der Startklasse bearbeiten.", null);
            StartClassForm.ShowDialog();
            FormHelper.getInstance().InitializeListViewWithStartClassListView(listViewStartClasses);
        }

        private void listViewRaces_DoubleClick(object sender, EventArgs e)
        {
            Race MyRace = Race.Get((Guid) listViewRaces.SelectedItems[0].Tag);
            frmRace RaceForm = new frmRace(FormName.RaceEdit, "Streckenbearbeitung", "Hier haben Sie die Möglichkeit die Daten einer Wettkampfstrecke zu verändern.", MyRace);
            RaceForm.ShowDialog();
            FormHelper.getInstance().InitializeListViewWithRaceListView(listViewRaces);
        }

        private void buttonNew_Click(object sender, EventArgs e)
        {
            frmRace RaceForm = new frmRace(FormName.RaceEdit, "Neue Strecke anlegen", "Hier haben Sie die Möglichkeit Eine neue Wettkampfstrecke anzulegen", null);
            RaceForm.ShowDialog();
            FormHelper.getInstance().InitializeListViewWithRaceListView(listViewRaces);
        }


        
    }
}


